﻿using SymulatorEthernetWPF.SimObjects.Devices;
using SymulatorEthernetWPF.SimObjects.Layers.DataLink;
using SymulatorEthernetWPF.UserInterface;
using System;
using System.Runtime.Serialization;

namespace SymulatorEthernetWPF.SimObjects
{
    [Serializable]
    public class TaskQueueItem: ISerializable
    {
        public MacAdress destination;
        public MacAdress source;
        public Guid sourceDeviceGUID;
        public int time;
        public int repeat;
        public bool active;
        


        public TaskQueueItem(Guid sourceDeviceGUID, MacAdress source,  MacAdress destination, int time, int repeat, bool active=true )
        {
            this.destination = destination;
            this.sourceDeviceGUID = sourceDeviceGUID;
            this.time = time;
            this.repeat = repeat;
            this.active = active;
            this.source = source;
        }

        public TaskQueueItem(SerializationInfo info, StreamingContext context)
        {
            destination = (MacAdress)info.GetValue("destination", typeof(MacAdress));
            sourceDeviceGUID = (Guid)info.GetValue("sourceDevice", typeof(Guid));
            source = (MacAdress)info.GetValue("source", typeof(MacAdress));
            time = (int)info.GetValue("time", typeof(int));
            repeat = (int)info.GetValue("repeat", typeof(int));
            active = (bool)info.GetValue("active", typeof(bool));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("destination", destination);
            info.AddValue("sourceDevice", sourceDeviceGUID);
            info.AddValue("source", source);
            info.AddValue("time", time);
            info.AddValue("repeat", repeat);
            info.AddValue("active", active);
        }

    }
}